// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue';
import iView from 'iview';
import VueRouter from 'vue-router';
import 'iview/dist/styles/iview.css';
import App from './App';
import Routers from './router/router';
import store from './store/';
import * as filters from './filters';
import './style/common.less';

Vue.use(VueRouter);
Vue.use(iView);

Vue.config.productionTip = false;

Object.keys(filters).forEach(k => Vue.filter(k, filters[k]));


// 路由配置
const RouterConfig = {
    // mode: 'history',
    routes: Routers,
};
const router = new VueRouter(RouterConfig);

router.beforeEach((to, from, next) => {
    iView.LoadingBar.start();
    next();
});

router.afterEach(() => {
    iView.LoadingBar.finish();
    window.scrollTo(0, 0);
});

/* eslint-disable no-new */
new Vue({
    el: '#app',
    router,
    store,
    template: '<App/>',
    components: { App },
});
